package com.tjian.fafa.user.base.bean;

import android.annotation.SuppressLint;

import com.tjian.fafa.user.base.commons.GlobalStrings;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ChatEntity
{
    public static final String strSplitter = GlobalStrings.entityDivider;

    private int mType = 0;
    private int mSenderId = 0;
    private int mSenderAvatarId = 0;
    private String mUserName = "xx";
    private int mSex = 0;
    private String mTime = "xx";
    private String mContent;
    private String mAvatarImagePath = "xx";
    private String oAvatarImagePath = "xx";
    private int mReceiverId = 0;

    public ChatEntity()
    {
    }

    public ChatEntity(int senderId, int avatarId, String name, int sex, String time, String content,
                      int receiverId)
    {
        this.mSenderId = senderId;
        this.mSenderAvatarId = avatarId;
        this.mUserName = name;
        this.mSex = sex;
        this.mTime = time;
        this.mContent = content;
        this.mReceiverId = receiverId;
    }

    public ChatEntity(int type, UserInfo userInfo_sender, int receiverId, String sentence, String imgpath)
    {
        this.mType = type;
        if (userInfo_sender == null)
        {
            return;
        }
        this.mSenderId = userInfo_sender.getId();
        this.mSenderAvatarId = userInfo_sender.getAvatarId();
        this.mUserName = userInfo_sender.getName();
        this.mSex = userInfo_sender.getSex();
        this.mTime = genDate();
        this.mContent = sentence;
        this.mReceiverId = receiverId;
        this.mAvatarImagePath = userInfo_sender.getmAvatarImagePath();
        this.oAvatarImagePath = imgpath;// ;
        //this.oAvatarImagePath = "imgs/avatar/2014/12/27/500fd9f9d72a6059794f269f2a34349b023bbadc.jpg";
        // 0"imgs/avatar/2014/12/27/haoren1.jpg"
    }

    public ChatEntity(String str0)
    {
        String[] sbArr0 = str0.split(strSplitter);
        mType = Integer.parseInt(sbArr0[0]);
        mSenderId = Integer.parseInt(sbArr0[1]);
        mSenderAvatarId = Integer.parseInt(sbArr0[2]);
        mUserName = sbArr0[3];
        mSex = Integer.parseInt(sbArr0[4]);
        mTime = sbArr0[5];
        mContent = sbArr0[6];
        mReceiverId = Integer.parseInt(sbArr0[7]);

        if (sbArr0.length > 8)
        {
            mAvatarImagePath = sbArr0[8];
            oAvatarImagePath = sbArr0[9];
        }
    }

    public String toString()
    {
        String str = this.mType + strSplitter;
        str += this.mSenderId + strSplitter;
        str += this.mSenderAvatarId + strSplitter;
        str += this.mUserName + strSplitter;
        str += this.mSex + strSplitter;
        str += this.mTime + strSplitter;
        str += this.mContent + strSplitter;
        str += this.mReceiverId + strSplitter;
        str += this.mAvatarImagePath + strSplitter;
        str += this.oAvatarImagePath + strSplitter;
        return str;
    }

    @SuppressLint("SimpleDateFormat")
    public static String genDate()
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        String timex = dateFormat.format(date);
        return timex;
    }

    public int getType()
    {
        return mType;
    }

    public void setType(int type0)
    {
        this.mType = type0;
    }

    public int getSenderId()
    {
        return mSenderId;
    }

    public void setSenderId(int senderId0)
    {
        this.mSenderId = senderId0;
    }

    public int getSenderAvatarid()
    {
        //	return senderAvatarId;
        if (mSex == 0)
        {
            return 0;
        }
        else
        {
            return 1;
        }
    }

    public void setSenderAvatarId(int senderAvatarId0)
    {
        this.mSenderAvatarId = senderAvatarId0;
    }

    public String getName()
    {
        return mUserName;
    }

    public void setName(String nick)
    {
        this.mUserName = nick;
    }

    public int getSex()
    {
        return mSex;
    }

    public void setSex(int sex)
    {
        this.mSex = sex;
    }

    public String getTime()
    {
        return mTime;
    }

    public void setTime(String time)
    {
        this.mTime = time;
    }

    public String getContent()
    {
        return mContent;
    }

    public void setContent(String content)
    {
        this.mContent = content;
    }

    public int getReceiverId()
    {
        return mReceiverId;
    }

    public void setReceiverId(int receiverId0)
    {
        this.mReceiverId = receiverId0;
    }

    public String getmAvatarImagePath()
    {
        return mAvatarImagePath;
    }

    public void setmAvatarImagePath(String mAvatarImagePath)
    {
        this.mAvatarImagePath = mAvatarImagePath;
    }

    public String getoAvatarImagePath()
    {
        return oAvatarImagePath;
    }

    public void setoAvatarImagePath(String oAvatarImagePath)
    {
        this.oAvatarImagePath = oAvatarImagePath;
    }
}